<template>
	<view class="content">
		<!-- <view class="content-bg">
			<u-navbar bgColor="transparent" titleStyle="color:#fff" title="社区" leftIconColor="transparent"
				:autoBack="true" :placeholder="false">
				<view class="right" slot="right">
					<image class="relate" src="/static/community/icon1.png" mode=""></image>
					<image class="add" src="/static/community/icon2.png" mode=""></image>
				</view>
			</u-navbar>
			<view class="content-box">
				<view style="height: 6vh;"></view>
				<view class="friend">
					<view class="friend-item" v-for="(item,index) in list" :key="index">
						<image :src="item.img" mode=""></image>
						<view class="item-right">
							<view class="right-text">
								<view class="name">
									{{item.name}}
								</view>
								<view class="msg">
									你好
								</view>
							</view>
							<view class="time">
								{{item.time}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-overlay :show="show" zIndex="100">
			<view class="tips">
				聊天室正在开发中...
			</view>
		</u-overlay> -->
		<web-view  :src="internalUrl"></web-view>
	</view>
</template>

<script>
	export default {
		props: {
		  url: {
		    type: String,
		    default: ''
		  }
		},
		data() {
			return {
				show: false,
				internalUrl:'',
				list: [{
					img: 'https://img1.baidu.com/it/u=3622150954,2575811681&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
					name: 'kk1314',
					time: '4-15 20:22'
				}, {
					img: 'https://q7.itc.cn/q_70/images03/20240423/6d236fae5c8f44ed9b60d977f32debb7.jpeg',
					name: '希望',
					time: '4-17 12:02'
				}, {
					img: 'https://q8.itc.cn/q_70/images03/20240413/6e2fab2f1ed34135be857cf8471d66f1.jpeg',
					name: '你说你是不是很傻',
					time: '3-17 18:12'
				}]
			}
		},
		watch: {
		  url(newValue) {
		    // 当 prop 的值发生变化时更新数据属性
		    this.internalUrl = newValue;
		  }
		},
		onShow() {
			this.islogin()
			
		},
		methods: {
			islogin() {
				let token = uni.getStorageSync('token')
				if (token == '' || token == undefined) {
					uni.showToast({
						title: '请先登录！',
						icon: 'none'
					})
					setTimeout(() => {
						uni.navigateTo({
							url: '/pages/login/index'
						})
					}, 1000)
					return
				}else{
					this.$Request({
						method: 'POST',
						url: '/api/Personal/myIndex',
						data: {}
					}).then(res => {
						if (res.code == 1) {
							// 本地
							// this.internalUrl = `http://localhost:8081/message/#/pages/Conversation/index?tel=${res.data.user.tel}`
							// 测试
							// this.internalUrl = `https://web.sunsk.top/message/#/pages/Conversation/index?tel=${res.data.user.tel}`
							// 正式
							this.internalUrl = `https://web.sunsk.top/message/#/pages/Conversation/index?tel=${res.data.user.tel}`
							console.log(this.internalUrl)
						} else {
							uni.showToast({
								title: res.msg,
								icon: 'none'
							})
						}
					})
				}
			},
		}
	}
</script>

<style>
	page {
		background: #1e0c4f;
	}
</style>
<style lang="scss" scoped>
	.tips {
		margin: 0 auto;
		color: #fff;
		margin-top: 100%;
		font-weight: 900;
	}

	.content {
		.content-bg {
			height: 544rpx;
			background-image: url('../../static/factory/head-bg.png');
			background-repeat: no-repeat;
			background-size: 100% 544rpx;

			.right {
				.relate {
					width: 31rpx;
					height: 32rpx;
				}

				.add {
					width: 34rpx;
					height: 34rpx;
					margin-left: 15rpx;
				}
			}

			.content-box {
				padding: 30rpx;

				.friend {
					.friend-item {
						display: flex;
						align-items: center;
						margin-bottom: 30rpx;

						image {
							width: 110rpx;
							height: 100rpx;
							border-radius: 10rpx;
						}

						.item-right {
							width: 100%;
							display: flex;
							justify-content: space-between;
							color: #999;
							font-size: 24rpx;
							margin-left: 30rpx;

							.right-text {
								.name {
									font-size: 28rpx;
									color: #fff;
								}

								.msg {
									margin-top: 10rpx;
								}
							}

							.time {}
						}
					}
				}
			}
		}
	}
</style>